home *** CD-ROM | disk | FTP | other *** search
- /****
- This snippet shows how to determine whether you are running on
- a Power Macintosh or on a 680x0 Macintosh. It also provides the
- method for determine exactly which type of processor is running.
- This works around an off-by-one error with gestaltNativeCPUType.
-
- Written by Virginia (Ginny) McCulloh
- Apple Developer Technical Support
- August 1995, Cupertino, CA
- Copyright 1995, Apple Computer, Inc.
-
- This runs under Think C 7.0.4, CodeWarrior 6,
- and MPW 3.3.1 with the Universal Headers.
- ****/
-
-
- #include <Gestalt.h>
- #include <stdio.h>
-
- Boolean hasPowerPCArch(void);
-
- void main()
- {
- OSErr err;
- long feature;
-
- /* First we will check the system architecture. */
- if (hasPowerPCArch()) /* It's a Power Macintosh of some sort */
- {
- /* What kind of Power Macintosh processor is this. */
- err = Gestalt (gestaltNativeCPUtype, &feature);
- if (0x100 & feature)
- {
- if (gestaltCPU601 == feature)
- printf( "\nThis puppy is a PowerMac with a 601 processor!");
- else if (gestaltCPU603 == feature)
- printf( "\nThis puppy is a PowerMac with a 603 processor!");
- else if (gestaltCPU604 == feature)
- printf( "\nThis puppy is a PowerMac with a 604 processor!");
- else
- printf( "\nThis must be some sort of PowerMac. I think.");
- }
- }
- else /* This is some sort of 68K machine */
- {
- err = Gestalt ( gestaltProcessorType, &feature );
- if (gestalt68040 == feature)
- printf( "\nThis is a 68040." );
- else if (gestalt68030 == feature)
- printf( "\nThis is a 68030.");
- else if (gestalt68020 == feature)
- printf( "\nThis is a 68020.");
- else if (gestalt68010 == feature)
- printf( "\nThis is a 68010.");
- else if (gestalt68000 == feature)
- printf( "\nThis is a 68000.");
- else
- printf( "\nI don't know what this is.");
-
- }
- }
-
- Boolean hasPowerPCArch()
- /*
- Gestalt will return an error if the gestaltSysArchitecture selector is
- not recognized by the System, so we can assume this is a 68K machine.
- Otherwise, this function returns true for a Power Mac and false for
- a 68K Mac.
- */
- {
- long gestaltResult;
-
- if (Gestalt(gestaltSysArchitecture, &gestaltResult))
- return(false);
- else
- return(gestaltResult == gestaltPowerPC);
- }
-